<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="common::common(title='基础数据')">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" ></meta>
</head>
<script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.config.js?v=20170409}"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.all.js}"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/ueditor/third-party/zeroclipboard/ZeroClipboard.js}"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.parse.js}"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/ueditor/lang/zh-cn/zh-cn.js}"></script>
<script type="text/javascript" th:src="@{/js/mall/subject.js?v=}+${new java.util.Date().getTime()}"></script>
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
  }
  .avatar {
    width: 100px;
    height: 100px;
    display: block;
  }
</style>

<body>
<div id="app" v-cloak>
  <el-container @keyup.enter.native="query">
	<el-header height="45px" class="inner_header">
	    	<el-form ref="form" :model="queryData" label-width="50px"  :label-position="labelPosition" >
		    	<el-row :gutter="20">
		    	<el-col :span="5">
				  	<el-form-item label="分类:" label-width="60px">
				  		<el-select v-model="queryData.classifyId" :size="size"  placeholder="请选择 " clearable>
						    <el-option
						      v-for="item in classifyOptions"
						      :key="item.id"
						      :label="item.name"
						      :value="item.id">
						    </el-option>
						  </el-select>
				    </el-form-item>
				  </el-col>
				  <el-col :span="5">
				  		<el-form-item label="标题:">
					  		<el-input placeholder="请输入标题" v-model="queryData.title" :size="size" clearable>
							</el-input>
						</el-form-item>
				  </el-col>
				  <el-col :span="5">
				  	<el-form-item label-width="0">
				  		<el-button type="primary" :size="size" icon="el-icon-search" @click="search">查询</el-button>
				  		<el-button type="primary" :size="size" icon="el-icon-plus" @click="addItem">增加</el-button>
				  	</el-form-item>
				  </el-col>
				</el-row>
	    	</el-form>
	    </el-header>
	    <el-main class="inner_main">
	    	<div>
	    	  <el-table  
	    	    ref="subjectDatagrid" 
	    	    :data="datagrid"
			    tooltip-effect="dark"
			    style="width: 100%;"
			    :height="tableHeight"
			    @row-click="datagridSelect"
			    v-loading="queryIng"
			    border
			    highlight-current-row
			    stripe
			    >
			    	<el-table-column type="index" label="序号" width="50"  align="center" header-align="center"></el-table-column>
				    <el-table-column prop="classifyName" label="分类" width="100" align="center" header-align="center"> </el-table-column>
				    <el-table-column prop="type" label="类型" width="100" align="center" header-align="center"> 
				     	<template slot-scope="scope">{{formatType(scope.row.type)}}</template>
				    </el-table-column>
				    <el-table-column prop="showStatus" label="显示状态" width="100" align="center" header-align="center">
				    	<template slot-scope="scope">{{scope.row.showStatus|formatYesNo}}</template>
				    </el-table-column>
				    <el-table-column prop="subjectUrl" label="文章连接" width="150" align="center" header-align="center"> </el-table-column>
				    <el-table-column prop="title" label="标题" width="100" align="center" header-align="center"> </el-table-column>
				    <el-table-column prop="pic" label="封面图" width="100" align="center" header-align="center"> 
				    	<template slot-scope="scope"><img style="height: 80px" :src="scope.row.coverImage"></template>
				    </el-table-column>
				    <el-table-column prop="createDate" label="创建时间" width="150" align="center" header-align="center"> </el-table-column>
				    <el-table-column  label="操作" fixed="right"  align="center" header-align="center">
				    	<template slot-scope="scope">
					        <el-button type="primary" size="small"  @click="editItem(scope.row)">编辑</el-button>
					        <el-button type="danger" size="small"  @click="deleteItem(scope.row)">删除</el-button>
					      </template>
				    </el-table-column>
			  </el-table>
			</div>
			<div class="pagination_wrap">
			    <el-pagination
			      :current-page="queryData.page"
			      :page-sizes="[10, 20, 40, 100]"
			      :page-size="queryData.rows"
			      :layout="pagination_layout"
			      :total="totalNum"
			      @size-change="handleSizeChange"
			      @current-change="handleCurrentChange"
			      @prev-click="handlePrevClick"
			      @next-click="handleNextClick">
			    </el-pagination>
			 </div>
	    </el-main>
	</el-container>
	<!-- dialog 开始 不需要【删除】 -->
	<el-dialog :visible.sync="dialogConfig.dialogFormVisible" :top="10" :close-on-click-modal="false" :show-close="false" fullscreen="true">
		  <el-form :model="addData" ref="dialogForm" :rules="rules">
		  	
		  	<el-form-item label="标题" prop="title" 
      		:label-width="dialogConfig.formLabelWidth">
			  	<el-input v-model="addData.title" :size="size"  auto-complete="off" style="width:220px;"></el-input>
		     </el-form-item>
		  	<el-form-item label="封面图" prop="coverImage" 
      		:label-width="dialogConfig.formLabelWidth">
		      	<el-upload
				  class="avatar-uploader"
				  accept="image/jpeg,image/gif,image/png,image/bmp"
				  :action="uploadUrl()"
				  :show-file-list="false"
				  :on-success="handleAvatarSuccess_coverImage"
				  :before-upload="beforeAvatarUpload">
	
				  <img v-if="imageUrl_coverImage" :src="imageUrl_coverImage" class="avatar">
				  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
				  
				</el-upload>
				
			</el-form-item>
			
			<el-form-item label="分类" prop="classifyId" 
      		:label-width="dialogConfig.formLabelWidth">
		    	<el-select v-model="addData.classifyId" :size="size"  placeholder="请选择 " style="width:220px;" @change="classifyChange">
				    <el-option
				      v-for="item in classifyOptions"
				      :key="item.id"
				      :label="item.name"
				      :value="item.id"
				      >
				    </el-option>
				</el-select>
		    </el-form-item>
			<el-form-item label="类型" prop="type" 
      		:label-width="dialogConfig.formLabelWidth">
		     	<el-select v-model="addData.type" :size="size"  placeholder="请选择 " style="width:220px;" @change="typeChange">
				    <el-option
				      v-for="item in typeOptions"
				      :key="item.value"
				      :label="item.label"
				      :value="item.value"
				      >
				    </el-option>
				</el-select>
		     </el-form-item>
		  	<el-form-item label="显示状态" prop="showStatus" 
      		:label-width="dialogConfig.formLabelWidth">
      			<el-switch
		          v-model="addData.showStatus"
		          :active-value="'1'"
		          :inactive-value="'0'">
		        </el-switch>
		     </el-form-item>
		  	<el-form-item label="文章连接" prop="subjectUrl"  v-show="addData.type==0"
      		:label-width="dialogConfig.formLabelWidth">
			  	<el-input v-model="addData.subjectUrl" :size="size"  auto-complete="off" style="width:220px;"></el-input>
		     </el-form-item>
			<el-form-item label="自定义内容" style="margin-left: 8%;" v-show="addData.type==1">
	        </el-form-item>
	        <el-form-item label="" style="margin-left: 8%;" v-show="addData.type==1">
      		  <script id="add_editor" type="text/plain" class="float-left" style=" height:400px;font-size: 14px; font-family: arial;"></script>
	        </el-form-item>
		  </el-form>
		  <div slot="footer" class="dialog-footer" style="text-align: center;">
		    <el-button @click="closeDialog" size="small">取 消</el-button>
		    <el-button type="primary" @click="submitForm('dialogForm')" size="small">确 定</el-button>
		  </div>
	 </el-dialog>
	 <!-- dialog 结束 -->
</div>
</body>
</html>